/**
 * @Title: TxdBarcodePrintUI.java
 * @Package com.rtmart.txd.barcode
 * @Description: 
 * @author Phoenix 
 * @version V1.0
 */
package com.rtmart.txd.barcode;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.border.EmptyBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.rtmart.txd.barcode.io.ConfigFile;
import com.rtmart.txd.barcode.json.Config;
import com.rtmart.txd.barcode.print.Print;
import com.rtmart.txd.barcode.print.WindowsPrint;

import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JComboBox;
import java.awt.Font;
import javax.swing.JButton;
import javax.swing.JTextField;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.SwingConstants;
import java.awt.event.ActionListener;
import java.io.File;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import java.awt.event.ActionEvent;
import javax.swing.event.CaretListener;
import javax.swing.event.CaretEvent;
import javax.swing.ButtonGroup;
import javax.swing.DefaultComboBoxModel; 

/**
 * @ClassName: TxdBarcodePrintUI
 * @Description:
 * @author Phoenix
 * @date 2018年3月12日 
 *
 */


@SuppressWarnings("unused")
public class TxdBarcodePrintUI extends JFrame {

	/**
	 * @Fields serialVersionUID : TODO(用一句话描述这个变量表示什么)
	 */
	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	public static JTextField textSeqStart;
	public static JTextField textSeqEnd;
	public static JTextField textSeqNo;
	public int comboIndex=0;
	public int prtIndex=0;
	public static String regExpWuLiuXiang = "^\\d{1,6}$";
	public static String regExpYuanGongHao = "^\\d{1,6}$";
	public static String regExpJianHuoDai = "^\\d{1,4}$";
	public static String regExpDaoKou = "^\\d{1,3}$";
	public static String regExpHouCangGongHao = "^\\d{1,6}$";
	public static String regExpJianHuoQu = "[Kk][1-9]{1}$";
	public static String regExpZouDao = "^[1-9][0-9]|[1-9]|[0][1-9]$";
	public static String regExpBei = "^[1-9][0-9]|[1-9]|[0][1-9]$";
	public static String regExpLiaoWei = "^[1-9][0-9]|[1-9]|[0][1-9]$";
	public static String regExpOldJianHuoDai = "^\\d{1,6}$";
	public static String regExpBanRiDa = "^\\d{1,8}$";
	public static String regExpBanRiDaBuYin = "^\\d{1,7}$";
	public static String regExpStoreNo = "^[1-5]\\d{1,3}$";
	public static String regExpDianCangQu = "^[1-9][0-9]$";
	public static String regExpDianCangBei = "^[1-9]|[1-9][0-9]$";
	public static String regExpDianCangDao = "^[1-9]|[1-9][0-9]|[1-9][0-9][0-9]$";
	public static String regExpDianCangCeng = "^[0-6]$";
	public static String regExpDianCangGe = "^[0-9]$";
	public static String regExpDianCangBar = "^[-0-9a-zA-Z]{1,20}$";
	public static String regExpZaiJu = "^[-0-9a-zA-Z]{1,4}$";
	public static String regExpZaiJuSeq = "^\\d{1,6}$";
	public static String regExpShiBie = "^[-a-zA-Z]{1,2}$";
	public static String regExpShiBieSeq = "^\\d{1,4}$";
	
	public static boolean txt1RegErr = false;
	public static boolean txt2RegErr = false;
	public static boolean txt4RegErr = false;
	public static boolean txt5RegErr = false;
	public static boolean txt6RegErr = false;
	public static boolean txt7RegErr = false;
	public static boolean txt8RegErr = false;
	public static boolean txtSeqNoErr = false;
	public static boolean txtStoreErr = false;
	public static boolean txtDianCangQuErr = false;
	public static boolean txtDianCangDaoErr = false;
	public static boolean txtDianCangCengErr = false;
	public static boolean txtDianCangGeErr = false;
	public static boolean txtDianCangBeiErr = false;
	public static boolean txtDianCangBarErr = false;
	public static boolean txtZaiJuErr = false;
	public static boolean txtShiBieErr = false;
	public static JTextField textField4;
	public static JTextField textField5;
	public static JTextField textField6;
	public static JTextField textField7;
	public static JTextField textField8;
	public static JTextField textDianCangQu;
	public static JTextField textDianCangDao;
	public static JTextField textDianCangBei;
	public static JTextField textDianCangCeng;
	public static JTextField textDianCangGe;
	public static JTextField textDianCangBar;
	public static JTextField textZaiJu;
	
	public static String configFile = "D:/txdbarcode/config/config.json"; 
	public static JTextField textStoreNo;
	public static String jsonConfigFileStr="";
	public static JComboBox<?> cmbPrinter=new JComboBox<Object>(new String[] {"rail3", "rail4"});
	public static JComboBox<?> cmbDianCangLou=new JComboBox<Object>(new String[] {"1F","2F","3F","1B","2B"});
	public static JComboBox<?> cmbWuLiuXiangLeiXing = new JComboBox<Object>(new String[] {"NM","RS","WK"});
	
	// 贾维程  新增控件声明
	public JRadioButton radioButtonZebra;
	public JRadioButton radioButtonWindows;
	//结束声明
	
	public static class TextThread extends Thread {
		@Override
		public void run() {
			while(true) {
				try {
					sleep(20);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				if (txt1RegErr ) {
					textSeqStart.setText(null);
					JOptionPane.showMessageDialog(null, "起始序号错误，请重新输入！");
					txt1RegErr = false;
				}
				if (txt2RegErr ) {
					textSeqEnd.setText(null);
					JOptionPane.showMessageDialog(null, "结束序号错误，请重新输入！");
					txt2RegErr = false;
				}
				if (txt4RegErr) {
					switch(textField4.getText().length()) {
					case 1:
						if (textField4.getText().equals("k")) {
//							textField4.setText("K");
							break;
						}
						else {
							JOptionPane.showMessageDialog(null, "拣货区号码首位必须是K，请重新输入！");
							textField4.setText(null);
						}
						break;
					default:
						JOptionPane.showMessageDialog(null, "拣货区号码不符合规则(K1-K9)，请重新输入！");
						textField4.setText(null);
						break;
					}
					txt4RegErr = false;
					

				}
				if (txt5RegErr) {
					textField5.setText(null);
					JOptionPane.showMessageDialog(null, "走道号码不符合规则(1-99)，请重新输入！");
					txt5RegErr = false;
				}
				if (txt6RegErr) {
					textField6.setText(null);
					JOptionPane.showMessageDialog(null, "背号不符合规则(1-99)，请重新输入！");
					txt6RegErr = false;
				}
				if (txt7RegErr) {
					textField7.setText(null);
					JOptionPane.showMessageDialog(null, "起始料位号不符合规则(1-99)，请重新输入！");
					txt7RegErr = false;
				}
				if (txt8RegErr) {
					textField8.setText(null);
					JOptionPane.showMessageDialog(null, "结束料位号不符合规则，请重新输入！");
					txt8RegErr = false;
				}
				if (txtDianCangQuErr) {
					textDianCangQu.setText(null);
					JOptionPane.showMessageDialog(null, "库区范围[10-99]，请重新输入！");
					textDianCangQu.requestFocus();
					txtDianCangQuErr = false;
				}
				if (txtDianCangDaoErr) {
					textDianCangDao.setText(null);
					JOptionPane.showMessageDialog(null, "通道范围[1-999]，请重新输入！");
					textDianCangDao.requestFocus();
					txtDianCangDaoErr = false;
				}
				if (txtDianCangBeiErr) {
					textDianCangBei.setText(null);
					JOptionPane.showMessageDialog(null, "背范围[1-99]，请重新输入！");
					textDianCangBei.requestFocus();
					txtDianCangBeiErr = false;
				}
				if (txtDianCangCengErr) {
					textDianCangCeng.setText(null);
					JOptionPane.showMessageDialog(null, "层数范围[0-6]，请重新输入！");
					textDianCangCeng.requestFocus();
					txtDianCangCengErr = false;
				}
				if (txtDianCangGeErr) {
					textDianCangGe.setText(null);
					JOptionPane.showMessageDialog(null, "格数范围[0-9]，请重新输入！");
					textDianCangGe.requestFocus();
					txtDianCangGeErr = false;
				}
				if (txtDianCangBarErr) {
					textDianCangBar.setText(null);
					JOptionPane.showMessageDialog(null, "料位不符合规则，请重新输入！");
					textDianCangBar.requestFocus();
					txtDianCangBarErr = false;
				}
				if (txtSeqNoErr) {
					textSeqNo.setText(null);
					JOptionPane.showMessageDialog(null, "流水号不符合规则，请重新输入！");
					txtSeqNoErr = false;
				}
				if (txtStoreErr) {
					textStoreNo.setText(null);
					JOptionPane.showMessageDialog(null, "店别错误（区号+门店号，共4位），请重新输入！");
					txtStoreErr = false;
				}
				if (txtZaiJuErr) {
					textZaiJu.setText(null);
					JOptionPane.showMessageDialog(null, "载具类型不符合规则（4位字符），请重新输入！");
					textZaiJu.requestFocus();
					txtZaiJuErr = false;
				}
				if (txtShiBieErr) {
					textZaiJu.setText(null);
					JOptionPane.showMessageDialog(null, "载具识别类型不符合规则（2位字符），请重新输入！");
					textZaiJu.requestFocus();
					txtShiBieErr = false;
				}
			}
		}
	}
	
	public boolean checkRegExp(String str,int i) {
		switch(i) {
		case 0:
			if ( str.matches(regExpWuLiuXiang) == false )
				return true;
			break;
		case 1:
			if ( str.matches(regExpDaoKou) == false )
				return true;
			break;
		case 2:
			if ( str.matches(regExpYuanGongHao) == false )
				return true;
			break;
		case 3:
			if ( str.matches(regExpJianHuoDai) == false )
				return true;
			break;
		case 5:
			if (str.matches(regExpHouCangGongHao) == false)
				return true;
			break;
		case 6:
			if (str.matches(regExpOldJianHuoDai)== false)
				return true;
			break;
		case 7:
			if (str.matches(regExpBanRiDa)==false)
				return true;
			break;
		case 8:
			if (str.matches(regExpBanRiDaBuYin)==false)
				return true;
			break;
		case 11:
			if (str.matches(regExpZaiJuSeq) == false)
				return true;
			break;
		case 12:
			if (str.matches(regExpShiBieSeq) == false)
				return true;
			break;
		}
		return false;
	}
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					ConfigFile.checkExist(configFile);
					jsonConfigFileStr = ConfigFile.readFile(configFile);
					JSONObject obj = JSON.parseObject(jsonConfigFileStr);
							
					TxdBarcodePrintUI frame = new TxdBarcodePrintUI();
					frame.setVisible(true);
					Thread resetText = new TextThread();
					resetText.start();
					TxdBarcodePrintUI.textStoreNo.setText(obj.getString("storeNo"));
					TxdBarcodePrintUI.cmbPrinter.setSelectedIndex(obj.getIntValue("prtIndex"));
					
					
//					System.out.println(jsonConfigFileStr);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public TxdBarcodePrintUI() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(500, 200, 900, 600);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(1, 1, 1, 1));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		JPanel panel = new JPanel();
		panel.setBorder(null);
		panel.setBackground(Color.LIGHT_GRAY);
		contentPane.add(panel, BorderLayout.CENTER);
		GridBagLayout gbl_panel = new GridBagLayout();
		gbl_panel.columnWidths = new int[] {100, 80,80,80, 80, 80,80,80,80,100, 0};
		gbl_panel.rowHeights = new int[] {100, 40, 40, 40,40,40,40, 40, 40,40,30, 0};
		gbl_panel.columnWeights = new double[]{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,Double.MIN_VALUE};
		gbl_panel.rowWeights = new double[]{0.0, 0.0, 0.0,0.0, 0.0,0.0,0.0,0.0,0.0,0.0,0.0,Double.MIN_VALUE};
		panel.setLayout(gbl_panel);
		
		JLabel labelTitle = new JLabel("淘鲜达条码列印");
		labelTitle.setFont(new Font("宋体", Font.BOLD, 27));
		GridBagConstraints gbc_labelTitle = new GridBagConstraints();
		gbc_labelTitle.gridwidth = 8;
		gbc_labelTitle.insets = new Insets(0, 0, 5, 5);
		gbc_labelTitle.gridx = 1;
		gbc_labelTitle.gridy = 0;
		panel.add(labelTitle, gbc_labelTitle);
		
		// 贾维程 新增内容开始 增加打印机选择
		/**
		 * @author 贾维程
		 * @date   2021-05-15
		 */
		JLabel labelPrint = new JLabel("请选择打印机：");
		labelPrint.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_labelPrint = new GridBagConstraints();
		gbc_labelPrint.gridwidth = 2;
		gbc_labelPrint.insets = new Insets(65, 15, 5, 5);
		gbc_labelPrint.gridx = 1;
		gbc_labelPrint.gridy = 0;
		panel.add(labelPrint, gbc_labelPrint);

		ButtonGroup buttonGroupPrint = new ButtonGroup();

		radioButtonZebra = new JRadioButton("条码打印机");
		radioButtonZebra.setSelected(true);
		radioButtonZebra.setFont(new Font("宋体", Font.PLAIN, 22));
		radioButtonZebra.setBackground(Color.LIGHT_GRAY);

		radioButtonWindows = new JRadioButton("其它打印机");
		radioButtonWindows.setFont(new Font("宋体", Font.PLAIN, 22));
		radioButtonWindows.setBackground(Color.LIGHT_GRAY);

		buttonGroupPrint.add(radioButtonZebra);
		buttonGroupPrint.add(radioButtonWindows);

		GridBagConstraints gbc_labelPrintZebra = new GridBagConstraints();
		gbc_labelPrintZebra.gridwidth = 2;
		gbc_labelPrintZebra.insets = new Insets(65, 15, 5, 5);
		gbc_labelPrintZebra.gridx = 3;
		gbc_labelPrintZebra.gridy = 0;
		panel.add(radioButtonZebra, gbc_labelPrintZebra);

		GridBagConstraints gbc_labelPrintWindows = new GridBagConstraints();
		gbc_labelPrintWindows.gridwidth = 2;
		gbc_labelPrintWindows.insets = new Insets(65, 15, 5, 5);
		gbc_labelPrintWindows.gridx = 5;
		gbc_labelPrintWindows.gridy = 0;
		panel.add(radioButtonWindows, gbc_labelPrintWindows);
		// 界面修改到此结束，处理事件在后面
		
		JLabel label1 = new JLabel("请选择列印条码类别：");
		label1.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_label1 = new GridBagConstraints();
		gbc_label1.gridwidth = 3;
		gbc_label1.insets = new Insets(0, 0,5,5);
		gbc_label1.gridx = 1;
		gbc_label1.gridy = 1;
		panel.add(label1, gbc_label1);

		String[] str= {"1.物流箱条码","2.道口条码","3.优鲜工号条码","4.拣货袋条码(店号开头)","5.快拣仓料位号","6.后仓工号条码","7.旧拣货袋条码(DD开头)","8.半日达原箱条码","9.半日达物流箱补印","10.店仓料位列印(批量)","11.店仓料位列印(单个)","12.店仓载具列印(批量)"};
		JComboBox<?> comboBox = new JComboBox<Object>(str);
		comboBox.setModel(new DefaultComboBoxModel(new String[] {"1.物流箱条码", "2.道口条码", "3.优鲜工号条码", "4.拣货袋条码(店号开头)", "5.快拣仓料位号", "6.后仓工号条码", "7.旧拣货袋条码(DD开头)", "8.半日达原箱条码", "9.半日达物流箱补印", "10.店仓料位列印(批量)", "11.店仓料位列印(单个)", "12.店仓载具列印(批量)", "13.MMC载具列印(批量)"}));
//		comboBox.setModel(new DefaultComboBoxModel(new String[] {"1.物流箱条码", "2.道口条码", "3.优鲜工号条码", "4.拣货袋条码(店号开头)", "5.快拣仓料位号", "6.后仓工号条码", "7.旧拣货袋条码(DD开头)", "8.半日达原箱条码", "9.半日达物流箱补印", "10.店仓料位列印(批量)", "11.店仓料位列印(单个)", "12.店仓载具列印(批量)"}));
		comboBox.setFont(new Font("宋体", Font.PLAIN, 20));
		GridBagConstraints gbc_comboBox = new GridBagConstraints();
		gbc_comboBox.fill = GridBagConstraints.BOTH;
		gbc_comboBox.gridwidth = 4;
		gbc_comboBox.insets = new Insets(0, 0, 5, 5);
		gbc_comboBox.gridx = 4;
		gbc_comboBox.gridy = 1;
		panel.add(comboBox, gbc_comboBox);
		
	
				
		JLabel label2 = new JLabel("请输入列印序号范围：");
		label2.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_label2 = new GridBagConstraints();
		gbc_label2.gridwidth = 3;
		gbc_label2.insets = new Insets(0, 0, 5, 5);
		gbc_label2.gridx = 1;
		gbc_label2.gridy = 2;
		panel.add(label2, gbc_label2);
		
		textSeqStart = new JTextField();
		textSeqStart.setHorizontalAlignment(SwingConstants.CENTER);
		textSeqStart.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_textSeqStart = new GridBagConstraints();
		gbc_textSeqStart.gridwidth = 2;
		gbc_textSeqStart.fill = GridBagConstraints.BOTH;
		gbc_textSeqStart.insets = new Insets(0, 0, 5, 5);
		gbc_textSeqStart.gridx = 4;
		gbc_textSeqStart.gridy = 2;
		panel.add(textSeqStart, gbc_textSeqStart);
		textSeqStart.setColumns(8);
		
		textSeqStart.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				txt1RegErr = checkRegExp(textSeqStart.getText(),comboIndex);
				if (textSeqStart.getText().isEmpty())
					textSeqStart.setText("1");
				textSeqEnd.requestFocus();
			}
		});
		
		textSeqStart.addCaretListener(new CaretListener() {
			public void caretUpdate(CaretEvent e) {
				if (textSeqStart.getText().isEmpty() == false) {
					txt1RegErr = checkRegExp(textSeqStart.getText(),comboIndex);
//					System.out.println("测试测试");
				}
			}
		});
		
		JLabel label3 = new JLabel("—");
		label3.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_label3 = new GridBagConstraints();
		gbc_label3.insets = new Insets(0, 0, 5, 5);
		gbc_label3.gridx = 6;
		gbc_label3.gridy = 2;
		panel.add(label3, gbc_label3);
		
		textSeqEnd = new JTextField();
		textSeqEnd.setHorizontalAlignment(SwingConstants.CENTER);
		textSeqEnd.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_textSeqEnd = new GridBagConstraints();
		gbc_textSeqEnd.gridwidth = 2;
		gbc_textSeqEnd.fill = GridBagConstraints.BOTH;
		gbc_textSeqEnd.insets = new Insets(0, 0, 5, 5);
		gbc_textSeqEnd.gridx = 7;
		gbc_textSeqEnd.gridy = 2;
		panel.add(textSeqEnd, gbc_textSeqEnd);
		textSeqEnd.setColumns(8);
		
//		textSeqStart.getDocument().addDocumentListener(new DocumentListener() {
//			public void changedUpdate(DocumentEvent e) {//这是更改操作的处理
//				txt1RegErr = checkRegExp(textSeqStart.getText(),comboIndex);
//			};
//			public void insertUpdate(DocumentEvent e) {//这是插入操作的处理
//				txt1RegErr = checkRegExp(textSeqStart.getText(),comboIndex);
//			};
//			public void removeUpdate(DocumentEvent e) {//这是删除操作的处理
//			    
//			}
//		});
		
		textSeqEnd.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
		txt2RegErr = checkRegExp(textSeqEnd.getText(),comboIndex);
		if (textSeqEnd.getText().isEmpty())
			textSeqEnd.setText("1");
		if (Integer.parseInt(textSeqEnd.getText()) < Integer.parseInt(textSeqStart.getText())) {
			textSeqEnd.setText(null);
			JOptionPane.showMessageDialog(null, "结束序号不能小于起始序号，请重新输入！");
			return;
		}
//				textSeqStart.requestFocus();
			}
		});
		
		textSeqEnd.addCaretListener(new CaretListener() {
			public void caretUpdate(CaretEvent e) {
				if (textSeqEnd.getText().isEmpty() == false) {
					txt2RegErr = checkRegExp(textSeqEnd.getText(),comboIndex);
//					System.out.println("测试测试");
				}
			}
		});
		
		JLabel label4 = new JLabel("拣货区");
		label4.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_label4 = new GridBagConstraints();
		gbc_label4.fill = GridBagConstraints.VERTICAL;
		gbc_label4.insets = new Insets(0, 0, 5, 5);
		gbc_label4.gridx = 3;
		gbc_label4.gridy = 3;
		panel.add(label4, gbc_label4);
		label4.setVisible(false);
		
		textField4 = new JTextField();
		textField4.setFont(new Font("宋体", Font.PLAIN, 20));
		GridBagConstraints gbc_textField4 = new GridBagConstraints();
		gbc_textField4.fill = GridBagConstraints.BOTH;
		gbc_textField4.insets = new Insets(0, 0, 5, 5);
		gbc_textField4.gridx = 4;
		gbc_textField4.gridy = 3;
		panel.add(textField4, gbc_textField4);
		textField4.setColumns(3);
		textField4.setVisible(false);

		textField4.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (textField4.getText().isEmpty())
					JOptionPane.showMessageDialog(null, "必须输入拣货区号！");
				txt4RegErr = !(textField4.getText().matches(regExpJianHuoQu));
				textField5.requestFocus();
			}
		});
		
		textField4.addCaretListener(new CaretListener() {
			public void caretUpdate(CaretEvent e) {
				if (textField4.getText().isEmpty() == false )
					switch (textField4.getText().length()) {
					case 1:
						txt4RegErr = !(textField4.getText().matches("^[K]$"));
						break;
					default :
						txt4RegErr = !(textField4.getText().matches(regExpJianHuoQu));
						break;
					}
			}
		});
		
		JLabel label5 = new JLabel("走道");
		label5.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_label5 = new GridBagConstraints();
		gbc_label5.fill = GridBagConstraints.VERTICAL;
		gbc_label5.insets = new Insets(0, 0, 5, 5);
		gbc_label5.gridx = 5;
		gbc_label5.gridy = 3;
		panel.add(label5, gbc_label5);
		label5.setVisible(false);
		
		textField5 = new JTextField();
		textField5.setFont(new Font("宋体", Font.PLAIN, 20));
		GridBagConstraints gbc_textField5 = new GridBagConstraints();
		gbc_textField5.insets = new Insets(0, 0, 5, 5);
		gbc_textField5.fill = GridBagConstraints.BOTH;
		gbc_textField5.gridx = 6;
		gbc_textField5.gridy = 3;
		panel.add(textField5, gbc_textField5);
		textField5.setColumns(3);
		textField5.setVisible(false);
		textField5.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				txt5RegErr = !(textField5.getText().matches(regExpZouDao));
				textField6.requestFocus();
			}
		});
		textField5.addCaretListener(new CaretListener() {
			public void caretUpdate(CaretEvent e) {
				if (textField5.getText().isEmpty() == false)
					switch(textField5.getText().length()) {
					case 1:
						txt5RegErr = !(textField5.getText().matches("^[0-9]$"));
						break;
					default:
						txt5RegErr = !(textField5.getText().matches(regExpZouDao));
						break;
					}
			}
		});
		
		JLabel label6 = new JLabel("背");
		label6.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_label6 = new GridBagConstraints();
		gbc_label6.fill = GridBagConstraints.VERTICAL;
		gbc_label6.insets = new Insets(0, 0, 5, 5);
		gbc_label6.gridx = 7;
		gbc_label6.gridy = 3;
		panel.add(label6, gbc_label6);
		label6.setVisible(false);
		
		textField6 = new JTextField();
		textField6.setFont(new Font("宋体", Font.PLAIN, 20));
		GridBagConstraints gbc_textField6 = new GridBagConstraints();
		gbc_textField6.insets = new Insets(0, 0, 5, 5);
		gbc_textField6.fill = GridBagConstraints.BOTH;
		gbc_textField6.gridx = 8;
		gbc_textField6.gridy = 3;
		panel.add(textField6, gbc_textField6);
		textField6.setColumns(3);
		textField6.setVisible(false);
		textField6.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				txt6RegErr = !(textField6.getText().matches(regExpBei));
				textField7.requestFocus();
			}
		});
		textField6.addCaretListener(new CaretListener() {
			public void caretUpdate(CaretEvent e) {
				if (textField6.getText().isEmpty() == false)
					switch(textField6.getText().length()) {
					case 1:
						txt6RegErr = !(textField6.getText().matches("^[0-9]$"));
						break;
					default:
						txt6RegErr = !(textField6.getText().matches(regExpBei));
						break;
					}
			}
		});
		
		JLabel label7 = new JLabel("料  位");
		label7.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_label7 = new GridBagConstraints();
		gbc_label7.fill = GridBagConstraints.VERTICAL;
		gbc_label7.insets = new Insets(0, 0, 5, 5);
		gbc_label7.gridx = 3;
		gbc_label7.gridy = 4;
		panel.add(label7, gbc_label7);
		label7.setVisible(false);
		
		textField7 = new JTextField();
		textField7.setFont(new Font("宋体", Font.PLAIN, 20));
		GridBagConstraints gbc_textField7 = new GridBagConstraints();
		gbc_textField7.insets = new Insets(0, 0, 5, 5);
		gbc_textField7.fill = GridBagConstraints.BOTH;
		gbc_textField7.gridx = 4;
		gbc_textField7.gridy = 4;
		panel.add(textField7, gbc_textField7);
		textField7.setColumns(3);
		textField7.setVisible(false);
		textField7.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				txt7RegErr = !(textField7.getText().matches(regExpLiaoWei));
				textField8.requestFocus();
			}
		});
		textField7.addCaretListener(new CaretListener() {
			public void caretUpdate(CaretEvent e) {
				if (textField7.getText().isEmpty() == false)
					switch(textField7.getText().length()) {
					case 1:
						txt7RegErr = !(textField7.getText().matches("^[0-9]$"));
						break;
					default:
						txt7RegErr = !(textField7.getText().matches(regExpLiaoWei));
						break;
					}
			}
		});
		
		JLabel label8 = new JLabel("—");
		label8.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_label8 = new GridBagConstraints();
		gbc_label8.fill = GridBagConstraints.VERTICAL;
		gbc_label8.insets = new Insets(0, 0, 5, 5);
		gbc_label8.gridx = 5;
		gbc_label8.gridy = 4;
		panel.add(label8, gbc_label8);
		label8.setVisible(false);
		
		textField8 = new JTextField();
		textField8.setFont(new Font("宋体", Font.PLAIN, 20));
		GridBagConstraints gbc_textField8 = new GridBagConstraints();
		gbc_textField8.insets = new Insets(0, 0, 5, 5);
		gbc_textField8.fill = GridBagConstraints.BOTH;
		gbc_textField8.gridx = 6;
		gbc_textField8.gridy = 4;
		panel.add(textField8, gbc_textField8);
		textField8.setColumns(3);
		textField8.setVisible(false);
		textField8.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				txt8RegErr = !(textField8.getText().matches(regExpLiaoWei));
				if (Integer.parseInt(textField8.getText()) < Integer.parseInt(textField7.getText())) {
					textField8.setText(null);
					JOptionPane.showMessageDialog(null, "结束料位号不能小于起始料位号！");
					return;
				}
			}
		});
		textField8.addCaretListener(new CaretListener() {
			public void caretUpdate(CaretEvent e) {
				if (textField8.getText().isEmpty() == false)
					switch(textField8.getText().length()) {
					case 1:
						txt8RegErr = !(textField8.getText().matches("^[0-9]$"));
						break;
					default:
						txt8RegErr = !(textField8.getText().matches(regExpLiaoWei));
						break;
					}
			}
		});
		
		JLabel labelDianCangQu = new JLabel("库区");
		labelDianCangQu.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_labelDianCangQu = new GridBagConstraints();
		gbc_labelDianCangQu.fill = GridBagConstraints.VERTICAL;
		gbc_labelDianCangQu.insets = new Insets(0, 0, 5, 5);
		gbc_labelDianCangQu.gridx = 3;
		gbc_labelDianCangQu.gridy = 3;
		panel.add(labelDianCangQu, gbc_labelDianCangQu);
		labelDianCangQu.setVisible(false);
		
		textDianCangQu = new JTextField();
		textDianCangQu.setFont(new Font("宋体", Font.PLAIN, 20));
		GridBagConstraints gbc_textDianCangQu = new GridBagConstraints();
		gbc_textDianCangQu.fill = GridBagConstraints.BOTH;
		gbc_textDianCangQu.insets = new Insets(0, 0, 5, 5);
		gbc_textDianCangQu.gridx = 4;
		gbc_textDianCangQu.gridy = 3;
		panel.add(textDianCangQu, gbc_textDianCangQu);
		textDianCangQu.setColumns(3);
		textDianCangQu.setVisible(false);

		textDianCangQu.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (textDianCangQu.getText().isEmpty())
					JOptionPane.showMessageDialog(null, "必须输入库区！");
				txtDianCangQuErr = !(textDianCangQu.getText().matches(regExpDianCangQu));
				cmbDianCangLou.requestFocus();
			}
		});
		
		JLabel labelDianCangLou = new JLabel("楼层");
		labelDianCangLou.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_labelDianCangLou = new GridBagConstraints();
		gbc_labelDianCangLou.fill = GridBagConstraints.VERTICAL;
		gbc_labelDianCangLou.insets = new Insets(0, 0, 5, 5);
		gbc_labelDianCangLou.gridx = 5;
		gbc_labelDianCangLou.gridy = 3;
		panel.add(labelDianCangLou, gbc_labelDianCangLou);
		labelDianCangLou.setVisible(false);
			
		cmbDianCangLou.setFont(new Font("宋体", Font.PLAIN, 20));
		GridBagConstraints gbc_cmbDianCangLou = new GridBagConstraints();
		gbc_cmbDianCangLou.fill = GridBagConstraints.BOTH;
		gbc_cmbDianCangLou.insets = new Insets(0, 0, 5, 5);
		gbc_cmbDianCangLou.gridx = 6;
		gbc_cmbDianCangLou.gridy = 3;
		panel.add(cmbDianCangLou, gbc_cmbDianCangLou);
		cmbDianCangLou.setVisible(false);
				
		JLabel labelDianCangDao = new JLabel("走道");
		labelDianCangDao.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_labelDianCangDao = new GridBagConstraints();
		gbc_labelDianCangDao.fill = GridBagConstraints.VERTICAL;
		gbc_labelDianCangDao.insets = new Insets(0, 0, 5, 5);
		gbc_labelDianCangDao.gridx = 7;
		gbc_labelDianCangDao.gridy = 3;
		panel.add(labelDianCangDao, gbc_labelDianCangDao);
		labelDianCangDao.setVisible(false);
		
		textDianCangDao = new JTextField();
		textDianCangDao.setFont(new Font("宋体", Font.PLAIN, 20));
		GridBagConstraints gbc_textDianCangDao = new GridBagConstraints();
		gbc_textDianCangDao.fill = GridBagConstraints.BOTH;
		gbc_textDianCangDao.insets = new Insets(0, 0, 5, 5);
		gbc_textDianCangDao.gridx = 8;
		gbc_textDianCangDao.gridy = 3;
		panel.add(textDianCangDao, gbc_textDianCangDao);
		textDianCangDao.setColumns(3);
		textDianCangDao.setVisible(false);
		
		textDianCangDao.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (textDianCangDao.getText().isEmpty())
					JOptionPane.showMessageDialog(null, "必须输入走道！");
				txtDianCangDaoErr = !(textDianCangDao.getText().matches(regExpDianCangDao));
				textDianCangBei.requestFocus();
			}
		});
		
		JLabel labelDianCangBei = new JLabel("背");
		labelDianCangBei.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_labelDianCangBei = new GridBagConstraints();
		gbc_labelDianCangBei.fill = GridBagConstraints.VERTICAL;
		gbc_labelDianCangBei.insets = new Insets(0, 0, 5, 5);
		gbc_labelDianCangBei.gridx = 3;
		gbc_labelDianCangBei.gridy = 4;
		panel.add(labelDianCangBei, gbc_labelDianCangBei);
		labelDianCangBei.setVisible(false);

		textDianCangBei = new JTextField();
		textDianCangBei.setFont(new Font("宋体", Font.PLAIN, 20));
		GridBagConstraints gbc_textDianCangBei = new GridBagConstraints();
		gbc_textDianCangBei.fill = GridBagConstraints.BOTH;
		gbc_textDianCangBei.insets = new Insets(0, 0, 5, 5);
		gbc_textDianCangBei.gridx = 4;
		gbc_textDianCangBei.gridy = 4;
		panel.add(textDianCangBei, gbc_textDianCangBei);
		textDianCangBei.setColumns(3);
		textDianCangBei.setVisible(false);
		
		textDianCangBei.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (textDianCangBei.getText().isEmpty())
					JOptionPane.showMessageDialog(null, "必须输入背！");
				txtDianCangBeiErr = !(textDianCangBei.getText().matches(regExpDianCangBei));
				textDianCangCeng.requestFocus();
			}
		});
		
		
		JLabel labelDianCangCeng = new JLabel("层数");
		labelDianCangCeng.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_labelDianCangCeng = new GridBagConstraints();
		gbc_labelDianCangCeng.fill = GridBagConstraints.VERTICAL;
		gbc_labelDianCangCeng.insets = new Insets(0, 0, 5, 5);
		gbc_labelDianCangCeng.gridx = 5;
		gbc_labelDianCangCeng.gridy = 4;
		panel.add(labelDianCangCeng, gbc_labelDianCangCeng);
		labelDianCangCeng.setVisible(false);

		textDianCangCeng = new JTextField();
		textDianCangCeng.setFont(new Font("宋体", Font.PLAIN, 20));
		GridBagConstraints gbc_textDianCangCeng = new GridBagConstraints();
		gbc_textDianCangCeng.fill = GridBagConstraints.BOTH;
		gbc_textDianCangCeng.insets = new Insets(0, 0, 5, 5);
		gbc_textDianCangCeng.gridx = 6;
		gbc_textDianCangCeng.gridy = 4;
		panel.add(textDianCangCeng, gbc_textDianCangCeng);
		textDianCangCeng.setColumns(3);
		textDianCangCeng.setVisible(false);		
		
		textDianCangCeng.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (textDianCangCeng.getText().isEmpty())
					JOptionPane.showMessageDialog(null, "必须输入层数！");
				txtDianCangCengErr = !(textDianCangCeng.getText().matches(regExpDianCangCeng));
				if ( Integer.parseInt(textDianCangCeng.getText()) == 0 ) {
					textDianCangGe.setText("0");
				    textDianCangGe.setEnabled(false);
				    
				}
				else
					textDianCangGe.setEnabled(true);
				    textDianCangGe.requestFocus();
			}
		});
		
		
		JLabel labelDianCangGe = new JLabel("格数");
		labelDianCangGe.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_labelDianCangGe = new GridBagConstraints();
		gbc_labelDianCangGe.fill = GridBagConstraints.VERTICAL;
		gbc_labelDianCangGe.insets = new Insets(0, 0, 5, 5);
		gbc_labelDianCangGe.gridx = 7;
		gbc_labelDianCangGe.gridy = 4;
		panel.add(labelDianCangGe, gbc_labelDianCangGe);
		labelDianCangGe.setVisible(false);		

		textDianCangGe = new JTextField();
		textDianCangGe.setFont(new Font("宋体", Font.PLAIN, 20));
		GridBagConstraints gbc_textDianCangGe = new GridBagConstraints();
		gbc_textDianCangGe.fill = GridBagConstraints.BOTH;
		gbc_textDianCangGe.insets = new Insets(0, 0, 5, 5);
		gbc_textDianCangGe.gridx = 8;
		gbc_textDianCangGe.gridy = 4;
		panel.add(textDianCangGe, gbc_textDianCangGe);
		textDianCangGe.setColumns(3);
		textDianCangGe.setVisible(false);		
		
		textDianCangGe.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (textDianCangGe.getText().isEmpty())
					JOptionPane.showMessageDialog(null, "必须输入格数！");
				txtDianCangGeErr = !(textDianCangGe.getText().matches(regExpDianCangGe));
			}
		});
		
		JLabel labelDianCangBar = new JLabel("料位条码字符：");
		labelDianCangBar.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_labelDianCangBar = new GridBagConstraints();
		gbc_labelDianCangBar.gridwidth = 2;
		gbc_labelDianCangBar.insets = new Insets(0, 0, 5, 5);
		gbc_labelDianCangBar.gridx = 2;
		gbc_labelDianCangBar.gridy = 5;
		panel.add(labelDianCangBar,gbc_labelDianCangBar);
		labelDianCangBar.setVisible(false);
		
		textDianCangBar = new JTextField();
		textDianCangBar.setFont(new Font("宋体", Font.PLAIN, 20));
		GridBagConstraints gbc_textDianCangBar = new GridBagConstraints();
		gbc_textDianCangBar.fill = GridBagConstraints.BOTH;
		gbc_textDianCangBar.gridwidth = 4;
		gbc_textDianCangBar.insets = new Insets(0, 0, 5, 5);
		gbc_textDianCangBar.gridx = 4;
		gbc_textDianCangBar.gridy = 5;
		panel.add(textDianCangBar, gbc_textDianCangBar);
		textDianCangBar.setColumns(20);
		textDianCangBar.setVisible(false);
		
		textDianCangBar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (textDianCangBar.getText().isEmpty())
					JOptionPane.showMessageDialog(null, "必须输入条码!");
				txtDianCangBarErr = !(textDianCangBar.getText().matches(regExpDianCangBar));
			}
		});
		
		JLabel labelZaiJu = new JLabel("  载具类型：");
		labelZaiJu.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_labelZaiJu = new GridBagConstraints();
		gbc_labelZaiJu.gridwidth = 2;
		gbc_labelZaiJu.insets = new Insets(0, 0, 5, 5);
		gbc_labelZaiJu.gridx = 2;
		gbc_labelZaiJu.gridy = 3;
		panel.add(labelZaiJu,gbc_labelZaiJu);
		labelZaiJu.setVisible(false);
		
		textZaiJu = new JTextField();
		textZaiJu.setFont(new Font("宋体", Font.PLAIN, 20));
		GridBagConstraints gbc_textZaiJu = new GridBagConstraints();
		gbc_textZaiJu.fill = GridBagConstraints.BOTH;
		gbc_textZaiJu.gridwidth = 1;
		gbc_textZaiJu.insets = new Insets(0, 0, 5, 5);
		gbc_textZaiJu.gridx = 4;
		gbc_textZaiJu.gridy = 3;
		panel.add(textZaiJu, gbc_textZaiJu);
		textZaiJu.setColumns(6);
		textZaiJu.setVisible(false);
		
		textZaiJu.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (textZaiJu.getText().isEmpty())
					JOptionPane.showMessageDialog(null, "必须输入载具类型!");
				if (comboBox.getSelectedIndex() == 11)
					txtZaiJuErr = !(textZaiJu.getText().matches(regExpZaiJu));
			}
		});
		textZaiJu.addCaretListener(new CaretListener() {
			public void caretUpdate(CaretEvent e) {
				if (textZaiJu.getText().isEmpty() == false) {
					if (comboBox.getSelectedIndex() == 11)
						txtZaiJuErr = !(textZaiJu.getText().matches(regExpZaiJu));
				}
					
			}
		});
		
		JLabel label9 = new JLabel("物流箱类型：");
		label9.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_label9 = new GridBagConstraints();
		gbc_label9.gridwidth = 2;
		gbc_label9.insets = new Insets(0, 0, 5, 5);
		gbc_label9.gridx = 2;
		gbc_label9.gridy = 5;
		panel.add(label9, gbc_label9);
		label9.setVisible(false);

//		cmbWuLiuXiangLeiXing.setModel(new DefaultComboBoxModel(new String[] {"NM", "RS", "WK"}));
		cmbWuLiuXiangLeiXing.setFont(new Font("宋体", Font.PLAIN, 20));
		GridBagConstraints gbc_cmbWuLiuXiangLeiXing = new GridBagConstraints();
		gbc_cmbWuLiuXiangLeiXing.fill = GridBagConstraints.BOTH;
		gbc_cmbWuLiuXiangLeiXing.insets = new Insets(0, 0, 5, 5);
		gbc_cmbWuLiuXiangLeiXing.gridx = 4;
		gbc_cmbWuLiuXiangLeiXing.gridy = 5;
		panel.add(cmbWuLiuXiangLeiXing, gbc_cmbWuLiuXiangLeiXing);
		cmbWuLiuXiangLeiXing.setVisible(false);
		
		JLabel label10 = new JLabel("流水号");
		label10.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_label10 = new GridBagConstraints();
		gbc_label10.gridwidth = 1;
		gbc_label10.insets = new Insets(0, 0, 5, 5);
		gbc_label10.gridx = 5;
		gbc_label10.gridy = 5;
		panel.add(label10, gbc_label10);
		label10.setVisible(false);
		
		textSeqNo = new JTextField();
		textSeqNo.setHorizontalAlignment(SwingConstants.CENTER);
		textSeqNo.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_textSeqNo = new GridBagConstraints();
		gbc_textSeqNo.gridwidth = 2;
		gbc_textSeqNo.fill = GridBagConstraints.BOTH;
		gbc_textSeqNo.insets = new Insets(0, 0, 5, 5);
		gbc_textSeqNo.gridx = 6;
		gbc_textSeqNo.gridy = 5;
		panel.add(textSeqNo, gbc_textSeqNo);
		textSeqNo.setColumns(8);
		textSeqNo.setVisible(false);
		
		textSeqNo.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				txtSeqNoErr = checkRegExp(textSeqNo.getText(),comboIndex);
				if (textSeqNo.getText().isEmpty())
					textSeqNo.setText("1");
				textSeqNo.requestFocus();
			}
		});
		
		textSeqNo.addCaretListener(new CaretListener() {
			public void caretUpdate(CaretEvent e) {
				if (textSeqNo.getText().isEmpty() == false) {
					txtSeqNoErr = checkRegExp(textSeqNo.getText(),comboIndex);
//					System.out.println("测试测试");
				}
			}
		});
		
		
		JLabel labelConfig = new JLabel("基本资料设置：");
		labelConfig.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_labelConfig = new GridBagConstraints();
		gbc_labelConfig.anchor = GridBagConstraints.WEST;
		gbc_labelConfig.gridwidth = 2;
		gbc_labelConfig.insets = new Insets(0, 0, 5, 5);
		gbc_labelConfig.gridx = 1;
		gbc_labelConfig.gridy = 6;
		panel.add(labelConfig, gbc_labelConfig);
		
		JLabel labelStore = new JLabel("店  别");
		labelStore.setFont(new Font("宋体", Font.PLAIN, 20));
		GridBagConstraints gbc_labelStore = new GridBagConstraints();
		gbc_labelStore.anchor = GridBagConstraints.EAST;
		gbc_labelStore.gridwidth = 1;
		gbc_labelStore.insets = new Insets(0, 0, 5, 5);
		gbc_labelStore.gridx = 3;
		gbc_labelStore.gridy = 6;
		panel.add(labelStore, gbc_labelStore);
		
		textStoreNo = new JTextField();
		textStoreNo.setFont(new Font("宋体", Font.PLAIN, 20));
		GridBagConstraints gbc_textStoreNo = new GridBagConstraints();
		gbc_textStoreNo.fill = GridBagConstraints.BOTH;
		gbc_textStoreNo.insets = new Insets(0, 0, 5, 5);
		gbc_textStoreNo.gridx = 4;
		gbc_textStoreNo.gridy = 6;
		panel.add(textStoreNo, gbc_textStoreNo);
		textStoreNo.setColumns(3);
		
		textStoreNo.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				txtStoreErr = !(textStoreNo.getText().matches(regExpStoreNo));
			}
		});
		textStoreNo.addCaretListener(new CaretListener() {
			public void caretUpdate(CaretEvent e) {
				if (textStoreNo.getText().isEmpty() == false)
					switch(textStoreNo.getText().length()) {
					case 1:
						txtStoreErr = !(textStoreNo.getText().matches("^[1-5]$"));
						break;
					default:
						txtStoreErr = !(textStoreNo.getText().matches(regExpStoreNo));
						break;
					}
			}
		});
		
		
		
		JLabel labelPrinter = new JLabel("打印机");
		labelPrinter.setFont(new Font("宋体", Font.PLAIN, 20));
		GridBagConstraints gbc_labelPrinter = new GridBagConstraints();
		gbc_labelPrinter.anchor = GridBagConstraints.EAST;
		gbc_labelPrinter.fill = GridBagConstraints.VERTICAL;
		gbc_labelPrinter.insets = new Insets(0, 0, 5, 5);
		gbc_labelPrinter.gridx = 6;
		gbc_labelPrinter.gridy = 6;
		panel.add(labelPrinter, gbc_labelPrinter);
		// 贾维程 禁用打印机选择框
		cmbPrinter.setEnabled(false);
		//
//		JComboBox<?> cmbPrinter = new JComboBox<Object>(new String[] {"rail3", "rail4"});
//		cmbPrinter.setModel(new DefaultComboBoxModel<Object>(new String[] {"rail3", "rail4"}));
		cmbPrinter.setFont(new Font("宋体", Font.PLAIN, 20));
		GridBagConstraints gbc_cmbPrinter = new GridBagConstraints();
		gbc_cmbPrinter.fill = GridBagConstraints.VERTICAL;
		gbc_cmbPrinter.insets = new Insets(0, 0, 5, 5);
		gbc_cmbPrinter.gridx = 7;
		gbc_cmbPrinter.gridy = 6;
		panel.add(cmbPrinter, gbc_cmbPrinter);
		
		JButton btnConfig = new JButton("保存设置");
		btnConfig.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_btnConfig = new GridBagConstraints();
		gbc_btnConfig.fill = GridBagConstraints.BOTH;
		gbc_btnConfig.gridwidth = 2;
		gbc_btnConfig.insets = new Insets(0, 0, 5, 5);
		gbc_btnConfig.gridx = 1;
		gbc_btnConfig.gridy = 7;
		panel.add(btnConfig, gbc_btnConfig);
		
		JButton btnPrint = new JButton("打印");
		btnPrint.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_btnPrint = new GridBagConstraints();
		gbc_btnPrint.fill = GridBagConstraints.BOTH;
		gbc_btnPrint.gridwidth = 2;
		gbc_btnPrint.insets = new Insets(0, 0, 5, 5);
		gbc_btnPrint.gridx = 4;
		gbc_btnPrint.gridy = 7;
		panel.add(btnPrint, gbc_btnPrint);
//		textSeqEnd.getDocument().addDocumentListener(new DocumentListener() {
//			public void changedUpdate(DocumentEvent e) {//这是更改操作的处理
//				txt2RegErr = checkRegExp(textSeqEnd.getText(),comboIndex);
//			};
//			public void insertUpdate(DocumentEvent e) {//这是插入操作的处理
//				txt2RegErr = checkRegExp(textSeqEnd.getText(),comboIndex);
//			};
//			public void removeUpdate(DocumentEvent e) {//这是删除操作的处理
//			    
//			}
//		});


		comboBox.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				comboIndex = comboBox.getSelectedIndex();
				textSeqStart.setText(null);
				textSeqEnd.setText(null);
				textField4.setText(null);
				textField5.setText(null);
				textField6.setText(null);
				textField7.setText(null);
				textField8.setText(null);
				textSeqNo.setText(null);
				textDianCangQu.setText(null);
				textDianCangDao.setText(null);
				textDianCangBei.setText(null);
				textDianCangGe.setText(null);
				textDianCangCeng.setText(null);
				textDianCangBar.setText(null);
				textZaiJu.setText(null);
				switch (comboIndex) {
				case 0:
				case 1:
				case 2:
				case 3:
				case 5:
				case 6:
				case 7:
					label4.setVisible(false);
					label5.setVisible(false);
					label6.setVisible(false);
					label7.setVisible(false);
					label8.setVisible(false);
					textField4.setVisible(false);
					textField5.setVisible(false);
					textField6.setVisible(false);
					textField7.setVisible(false);
					textField8.setVisible(false);
					labelDianCangQu.setVisible(false);
					labelDianCangLou.setVisible(false);
					labelDianCangDao.setVisible(false);
					labelDianCangBei.setVisible(false);
					labelDianCangCeng.setVisible(false);
					labelDianCangGe.setVisible(false);
					textDianCangQu.setVisible(false);
					textDianCangDao.setVisible(false);
					textDianCangBei.setVisible(false);
					textDianCangCeng.setVisible(false);
					textDianCangGe.setVisible(false);
					cmbDianCangLou.setVisible(false);
					labelDianCangBar.setVisible(false);
					textDianCangBar.setVisible(false);
					labelZaiJu.setVisible(false);
					textZaiJu.setVisible(false);
					label2.setVisible(true);
					label3.setVisible(true);
					textSeqStart.setVisible(true);
					textSeqEnd.setVisible(true);
					label9.setVisible(false);
					label10.setVisible(false);
					cmbWuLiuXiangLeiXing.setVisible(false);
					textSeqNo.setVisible(false);
					break;
				case 4:
					label4.setVisible(true);
					label5.setVisible(true);
					label6.setVisible(true);
					label7.setVisible(true);
					label8.setVisible(true);
					textField4.setVisible(true);
					textField5.setVisible(true);
					textField6.setVisible(true);
					textField7.setVisible(true);
					textField8.setVisible(true);
					labelDianCangQu.setVisible(false);
					labelDianCangLou.setVisible(false);
					labelDianCangDao.setVisible(false);
					labelDianCangBei.setVisible(false);
					labelDianCangCeng.setVisible(false);
					labelDianCangGe.setVisible(false);
					textDianCangQu.setVisible(false);
					textDianCangDao.setVisible(false);
					textDianCangBei.setVisible(false);
					textDianCangCeng.setVisible(false);
					textDianCangGe.setVisible(false);
					cmbDianCangLou.setVisible(false);
					labelDianCangBar.setVisible(false);
					textDianCangBar.setVisible(false);
					labelZaiJu.setVisible(false);
					textZaiJu.setVisible(false);
					label2.setVisible(false);
					label3.setVisible(false);
					textSeqStart.setVisible(false);
					textSeqEnd.setVisible(false);
					label9.setVisible(false);
					label10.setVisible(false);
					cmbWuLiuXiangLeiXing.setVisible(false);
					textSeqNo.setVisible(false);
					break;
				case 8:
					label4.setVisible(false);
					label5.setVisible(false);
					label6.setVisible(false);
					label7.setVisible(false);
					label8.setVisible(false);
					textField4.setVisible(false);
					textField5.setVisible(false);
					textField6.setVisible(false);
					textField7.setVisible(false);
					textField8.setVisible(false);
					labelDianCangQu.setVisible(false);
					labelDianCangLou.setVisible(false);
					labelDianCangDao.setVisible(false);
					labelDianCangBei.setVisible(false);
					labelDianCangCeng.setVisible(false);
					labelDianCangGe.setVisible(false);
					textDianCangQu.setVisible(false);
					textDianCangDao.setVisible(false);
					textDianCangBei.setVisible(false);
					textDianCangCeng.setVisible(false);
					textDianCangGe.setVisible(false);
					cmbDianCangLou.setVisible(false);
					labelDianCangBar.setVisible(false);
					textDianCangBar.setVisible(false);
					labelZaiJu.setVisible(false);
					textZaiJu.setVisible(false);
					label2.setVisible(false);
					label3.setVisible(false);
					textSeqStart.setVisible(false);
					textSeqEnd.setVisible(false);
					label9.setVisible(true);
					label10.setVisible(true);
					cmbWuLiuXiangLeiXing.setVisible(true);
					textSeqNo.setVisible(true);
					break;
				case 9:
					label4.setVisible(false);
					label5.setVisible(false);
					label6.setVisible(false);
					label7.setVisible(false);
					label8.setVisible(false);
					textField4.setVisible(false);
					textField5.setVisible(false);
					textField6.setVisible(false);
					textField7.setVisible(false);
					textField8.setVisible(false);
					labelDianCangQu.setVisible(true);
					labelDianCangLou.setVisible(true);
					labelDianCangDao.setVisible(true);
					labelDianCangBei.setVisible(true);
					labelDianCangCeng.setVisible(true);
					labelDianCangGe.setVisible(true);
					textDianCangQu.setVisible(true);
					textDianCangDao.setVisible(true);
					textDianCangBei.setVisible(true);
					textDianCangCeng.setVisible(true);
					textDianCangGe.setVisible(true);
					cmbDianCangLou.setVisible(true);
					labelDianCangBar.setVisible(false);
					textDianCangBar.setVisible(false);
					labelZaiJu.setVisible(false);
					textZaiJu.setVisible(false);
					label2.setVisible(false);
					label3.setVisible(false);
					textSeqStart.setVisible(false);
					textSeqEnd.setVisible(false);
					label9.setVisible(false);
					label10.setVisible(false);
					cmbWuLiuXiangLeiXing.setVisible(false);
					textSeqNo.setVisible(false);
					break;
				case 10:
					label4.setVisible(false);
					label5.setVisible(false);
					label6.setVisible(false);
					label7.setVisible(false);
					label8.setVisible(false);
					textField4.setVisible(false);
					textField5.setVisible(false);
					textField6.setVisible(false);
					textField7.setVisible(false);
					textField8.setVisible(false);
					labelDianCangQu.setVisible(false);
					labelDianCangLou.setVisible(false);
					labelDianCangDao.setVisible(false);
					labelDianCangBei.setVisible(false);
					labelDianCangCeng.setVisible(false);
					labelDianCangGe.setVisible(false);
					textDianCangQu.setVisible(false);
					textDianCangDao.setVisible(false);
					textDianCangBei.setVisible(false);
					textDianCangCeng.setVisible(false);
					textDianCangGe.setVisible(false);
					cmbDianCangLou.setVisible(false);
					labelDianCangBar.setVisible(true);
					textDianCangBar.setVisible(true);
					labelZaiJu.setVisible(false);
					textZaiJu.setVisible(false);
					label2.setVisible(false);
					label3.setVisible(false);
					textSeqStart.setVisible(false);
					textSeqEnd.setVisible(false);
					label9.setVisible(false);
					label10.setVisible(false);
					cmbWuLiuXiangLeiXing.setVisible(false);
					textSeqNo.setVisible(false);
					break;
				case 11:
					label4.setVisible(false);
					label5.setVisible(false);
					label6.setVisible(false);
					label7.setVisible(false);
					label8.setVisible(false);
					textField4.setVisible(false);
					textField5.setVisible(false);
					textField6.setVisible(false);
					textField7.setVisible(false);
					textField8.setVisible(false);
					labelDianCangQu.setVisible(false);
					labelDianCangLou.setVisible(false);
					labelDianCangDao.setVisible(false);
					labelDianCangBei.setVisible(false);
					labelDianCangCeng.setVisible(false);
					labelDianCangGe.setVisible(false);
					textDianCangQu.setVisible(false);
					textDianCangDao.setVisible(false);
					textDianCangBei.setVisible(false);
					textDianCangCeng.setVisible(false);
					textDianCangGe.setVisible(false);
					cmbDianCangLou.setVisible(false);
					labelDianCangBar.setVisible(false);
					textDianCangBar.setVisible(false);
					labelZaiJu.setVisible(true);
					textZaiJu.setVisible(true);
					labelZaiJu.setText("载具类型：");
					label2.setVisible(true);
					label3.setVisible(true);
					textSeqStart.setVisible(true);
					textSeqEnd.setVisible(true);
					label9.setVisible(false);
					label10.setVisible(false);
					cmbWuLiuXiangLeiXing.setVisible(false);
					textSeqNo.setVisible(false);
					break;
				case 12:
					label4.setVisible(false);
					label5.setVisible(false);
					label6.setVisible(false);
					label7.setVisible(false);
					label8.setVisible(false);
					textField4.setVisible(false);
					textField5.setVisible(false);
					textField6.setVisible(false);
					textField7.setVisible(false);
					textField8.setVisible(false);
					labelDianCangQu.setVisible(false);
					labelDianCangLou.setVisible(false);
					labelDianCangDao.setVisible(false);
					labelDianCangBei.setVisible(false);
					labelDianCangCeng.setVisible(false);
					labelDianCangGe.setVisible(false);
					textDianCangQu.setVisible(false);
					textDianCangDao.setVisible(false);
					textDianCangBei.setVisible(false);
					textDianCangCeng.setVisible(false);
					textDianCangGe.setVisible(false);
					cmbDianCangLou.setVisible(false);
					labelDianCangBar.setVisible(false);
					textDianCangBar.setVisible(false);
					labelZaiJu.setVisible(true);
					labelZaiJu.setText("载具识别码：");
					textZaiJu.setVisible(true);
					label2.setVisible(true);
					label3.setVisible(true);
					textSeqStart.setVisible(true);
					textSeqEnd.setVisible(true);
					label9.setVisible(false);
					label10.setVisible(false);
					cmbWuLiuXiangLeiXing.setVisible(false);
					textSeqNo.setVisible(false);
					

				}
				
				
//				System.out.println(comboIndex);
			}
		});
		
		cmbPrinter.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				prtIndex = cmbPrinter.getSelectedIndex();
			}
		});
		
		btnConfig.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Config cfg = new Config();
				cfg.setStoreNo(TxdBarcodePrintUI.textStoreNo.getText());
				cfg.setPrtIndex(TxdBarcodePrintUI.cmbPrinter.getSelectedIndex());
				jsonConfigFileStr = JSON.toJSONString(cfg);
				ConfigFile.saveConfigFile(configFile, jsonConfigFileStr);
			}  
		});
		
		btnPrint.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Print prt2 = new Print();
			    if  (textStoreNo.getText().matches("^[1-5][0-9][0-9][0-9]$") == false) {
			    	JOptionPane.showMessageDialog(null, "店别错误（区号+门店号，共4位），请重新输入并保存设置！");
			        textStoreNo.setText(null);
			    	return;
			    }
				switch (comboIndex) {
				case 4:
					if (textField4.getText().isEmpty() || textField5.getText().isEmpty() || textField6.getText().isEmpty() ||
						textField7.getText().isEmpty() || textField8.getText().isEmpty() ) {
						JOptionPane.showMessageDialog(null, "请检查列印料位所需栏位是否输入完毕！");
						return;
					}
					else {
						if (Integer.parseInt(textField8.getText()) < Integer.parseInt(textField7.getText())) {
							textField8.setText(null);
							JOptionPane.showMessageDialog(null, "结束料位号不能小于起始料位号！");
							return;
						}
						/**
						for (int i = Integer.parseInt(textField7.getText()); i <= Integer
								.parseInt(textField8.getText()); i++) {
							if (!prt.barcodePrint(textField4.getText(), Integer.parseInt(textField5.getText()), Integer.parseInt(textField6.getText()), i,prtIndex))
								return;
						}
						*/
						/** 贾维程 替换的内容
						 * @author 贾维程
						 * @date   2021-05-15
						 */
						if (radioButtonZebra.isSelected()){
							Print prt = new Print("init ZplPrinter");
							for (int i = Integer.parseInt(textField7.getText()); i <= Integer.parseInt(textField8.getText()); i++) {
								if (!prt.barcodePrint(textField4.getText(), Integer.parseInt(textField5.getText()), Integer.parseInt(textField6.getText()), i, 0))
									return;
							}
						} else {
							List<String> barCodeList = new ArrayList<>();
							for (int i = Integer.parseInt(textField7.getText()); i <= Integer.parseInt(textField8.getText()); i++) {
								try {
									barCodeList.add(prt2.getBarcode(textField4.getText(), Integer.parseInt(textField5.getText()), Integer.parseInt(textField6.getText()), i));
								} catch (Exception e1) {
									JOptionPane.showMessageDialog(null, "Windows打印获取条码异常！");
									return;
								}
							}
							WindowsPrint windowsPrint = new WindowsPrint(barCodeList);
							if(!windowsPrint.print()) return;
							else JOptionPane.showMessageDialog(null, "打印完成！");
						}
					}
					break;
				case 8:
					if (textSeqNo.getText().isEmpty()){
						JOptionPane.showMessageDialog(null, "流水号不能为空！");
						return;
					}
					/*
					if (!prt.barcodePrint(Integer.parseInt(textSeqNo.getText()),cmbWuLiuXiangLeiXing.getSelectedItem().toString() ,prtIndex))
						return;
					*/
					/** 贾维程 替换的内容
					 * @author 贾维程
					 * @date   2021-05-15
					 */
					if (radioButtonZebra.isSelected()){
						Print prt = new Print("init ZplPrinter");
						if (!prt.barcodePrint(Integer.parseInt(textSeqNo.getText()),cmbWuLiuXiangLeiXing.getSelectedItem().toString() ,prtIndex))
							return;
					} else {
						List<String> barCodeList = new ArrayList<>();
						try {
							barCodeList.add(prt2.getBarcode(Integer.parseInt(textSeqNo.getText()),cmbWuLiuXiangLeiXing.getSelectedItem().toString()));
						} catch (Exception e1) {
							JOptionPane.showMessageDialog(null, "Windows打印获取条码异常！");
							e1.printStackTrace();
						}
						WindowsPrint windowsPrint = new WindowsPrint(barCodeList);
						if(!windowsPrint.print()) return;
						else JOptionPane.showMessageDialog(null, "打印完成！");
					}
					break;
				case 9:
					if (textDianCangQu.getText().isEmpty() || textDianCangDao.getText().isEmpty() || textDianCangBei.getText().isEmpty() ||
							textDianCangCeng.getText().isEmpty() || textDianCangGe.getText().isEmpty() ) {
							JOptionPane.showMessageDialog(null, "请检查列店仓印料位所需栏位是否输入完毕！");
							return;
					}
					/*
					if (Integer.parseInt(textDianCangCeng.getText()) == 0 ) {
						if (!prt.barcodePrintDianCang(Integer.parseInt(textDianCangQu.getText()),cmbDianCangLou.getSelectedIndex(),Integer.parseInt(textDianCangDao.getText()),
							 Integer.parseInt(textDianCangBei.getText()),Integer.parseInt(textDianCangCeng.getText()),Integer.parseInt(textDianCangGe.getText()), prtIndex))
							return;
					}
					else {
						for (int i = 1; i <= Integer.parseInt(textDianCangCeng.getText());i++) {
							if (Integer.parseInt(textDianCangGe.getText()) == 0 ) {
								if (!prt.barcodePrintDianCang(Integer.parseInt(textDianCangQu.getText()),cmbDianCangLou.getSelectedIndex(),Integer.parseInt(textDianCangDao.getText()),
										 Integer.parseInt(textDianCangBei.getText()),i,Integer.parseInt(textDianCangGe.getText()), prtIndex))
										return;
							}
							else {
								for (int j = 1;j <= Integer.parseInt(textDianCangGe.getText());j++ ) {
									if (!prt.barcodePrintDianCang(Integer.parseInt(textDianCangQu.getText()),cmbDianCangLou.getSelectedIndex(),Integer.parseInt(textDianCangDao.getText()),
											 Integer.parseInt(textDianCangBei.getText()),i,j, prtIndex))
											return;
								}
							}
						}
					}
					*/
					/** 贾维程 替换的内容
					 * @author 贾维程
					 * @date   2021-05-15
					 */
					if (radioButtonZebra.isSelected()){
						Print prt = new Print("init ZplPrinter");
						if (Integer.parseInt(textDianCangCeng.getText()) == 0 ) {
							if (!prt.barcodePrintDianCang(Integer.parseInt(textDianCangQu.getText()),cmbDianCangLou.getSelectedIndex(),Integer.parseInt(textDianCangDao.getText()),
								 Integer.parseInt(textDianCangBei.getText()),Integer.parseInt(textDianCangCeng.getText()),Integer.parseInt(textDianCangGe.getText()), prtIndex))
								return;
						}
						else {
							for (int i = 1; i <= Integer.parseInt(textDianCangCeng.getText());i++) {
								if (Integer.parseInt(textDianCangGe.getText()) == 0 ) {
									if (!prt.barcodePrintDianCang(Integer.parseInt(textDianCangQu.getText()),cmbDianCangLou.getSelectedIndex(),Integer.parseInt(textDianCangDao.getText()),
											 Integer.parseInt(textDianCangBei.getText()),i,Integer.parseInt(textDianCangGe.getText()), prtIndex))
											return;
								}
								else {
									for (int j = 1;j <= Integer.parseInt(textDianCangGe.getText());j++ ) {
										if (!prt.barcodePrintDianCang(Integer.parseInt(textDianCangQu.getText()),cmbDianCangLou.getSelectedIndex(),Integer.parseInt(textDianCangDao.getText()),
												 Integer.parseInt(textDianCangBei.getText()),i,j, prtIndex))
												return;
									}
								}
							}
						}
					} else {
						List<String> barCodeList = new ArrayList<>();
						if (Integer.parseInt(textDianCangCeng.getText()) == 0 ) {
							barCodeList.add(prt2.getBarcode(Integer.parseInt(textDianCangQu.getText()),cmbDianCangLou.getSelectedIndex(),Integer.parseInt(textDianCangDao.getText()),
								 Integer.parseInt(textDianCangBei.getText()),Integer.parseInt(textDianCangCeng.getText()),Integer.parseInt(textDianCangGe.getText())));
						}
						else {
							for (int i = 1; i <= Integer.parseInt(textDianCangCeng.getText());i++) {
								if (Integer.parseInt(textDianCangGe.getText()) == 0 ) {
									barCodeList.add(prt2.getBarcode(Integer.parseInt(textDianCangQu.getText()),cmbDianCangLou.getSelectedIndex(),Integer.parseInt(textDianCangDao.getText()),
											 Integer.parseInt(textDianCangBei.getText()),i,Integer.parseInt(textDianCangGe.getText())));
								}
								else {
									for (int j = 1;j <= Integer.parseInt(textDianCangGe.getText());j++ ) {
										barCodeList.add(prt2.getBarcode(Integer.parseInt(textDianCangQu.getText()),cmbDianCangLou.getSelectedIndex(),Integer.parseInt(textDianCangDao.getText()),
												 Integer.parseInt(textDianCangBei.getText()),i,j));
									}
								}
							}
						}
						WindowsPrint windowsPrint = new WindowsPrint(barCodeList);
						if(!windowsPrint.print()) return;
						else JOptionPane.showMessageDialog(null, "打印完成！");
					}
					break;
				case 10:
					if (textDianCangBar.getText().isEmpty() ) {
							JOptionPane.showMessageDialog(null, "请检查列店仓印料位所需栏位是否输入完毕！");
							return;
					}
					/*
					if (!prt.barcodePrintDianCang(textDianCangBar.getText(), prtIndex))
						return;
					*/
					/** 贾维程 替换的内容
					 * @author 贾维程
					 * @date   2021-05-15
					 */
					if (radioButtonZebra.isSelected()){
						Print prt = new Print("init ZplPrinter");
						if (!prt.barcodePrintDianCang(textDianCangBar.getText(), prtIndex))
							return;
					} else {
						List<String> barCodeList = new ArrayList<>();
						barCodeList.add(textDianCangBar.getText());
						WindowsPrint windowsPrint = new WindowsPrint(barCodeList);
						if(!windowsPrint.print()) return;
						else JOptionPane.showMessageDialog(null, "打印完成！");
					}
					break;
				case 11:
					if (textSeqStart.getText().isEmpty() || textSeqEnd.getText().isEmpty()) {
						JOptionPane.showMessageDialog(null, "起讫序号不能为空，输入完毕才能列印！");
						return;
					} 
					else {
//						txt1RegErr = checkRegExp(textSeqStart.getText(),comboIndex);
//						txt1RegErr = checkRegExp(textSeqEnd.getText(),comboIndex);
						if (comboIndex != 7) {
							if (Integer.parseInt(textSeqEnd.getText()) > Integer.parseInt(textSeqStart.getText()) + 100) {
								textSeqEnd.setText(null);
								JOptionPane.showMessageDialog(null, "为避免浪费，不建议一次性列印超过100张条码，请重新输入结束序号！");
								return;
							}
						}
						if (Integer.parseInt(textSeqEnd.getText()) < Integer.parseInt(textSeqStart.getText())) {
							textSeqEnd.setText(null);
							JOptionPane.showMessageDialog(null, "结束序号不能小于起始序号！");
							return;
						}
						if ( textZaiJu.getText().matches("^[-0-9a-zA-Z]{4}$") == false ) { 
							textZaiJu.requestFocus();
							JOptionPane.showMessageDialog(null, "请输入正确的载具类型（4位字符）！");
							return;
						}
						/*
						for (int i = Integer.parseInt(textSeqStart.getText()); i <= Integer
								.parseInt(textSeqEnd.getText()); i++) {
							if (!prt.barcodePrintZaiJu(i, textZaiJu.getText(),prtIndex))
								return;
						}
						*/
						/** 贾维程 替换的内容
						 * @author 贾维程
						 * @date   2021-05-15
						 */
						if (radioButtonZebra.isSelected()){
							Print prt = new Print("init ZplPrinter");
							for (int i = Integer.parseInt(textSeqStart.getText()); i <= Integer
									.parseInt(textSeqEnd.getText()); i++) {
								if (!prt.barcodePrintZaiJu(i, textZaiJu.getText(),prtIndex))
									return;
							}
						} else {
							List<String> barCodeList = new ArrayList<>();
							for (int i = Integer.parseInt(textSeqStart.getText()); i <= Integer
									.parseInt(textSeqEnd.getText()); i++) {
								try {
									barCodeList.add(prt2.getBarcodeZaiJu(i, textZaiJu.getText()));
								} catch (Exception e1) {
									JOptionPane.showMessageDialog(null, "Windows打印获取条码异常！");
									return;
								}
							}
							WindowsPrint windowsPrint = new WindowsPrint(barCodeList);
							if(!windowsPrint.print()) return;
							else JOptionPane.showMessageDialog(null, "打印完成！");
						}
					}
					break;
				case 12:
					if (textSeqStart.getText().isEmpty() || textSeqEnd.getText().isEmpty()) {
						JOptionPane.showMessageDialog(null, "起讫序号不能为空，输入完毕才能列印！");
						return;
					} 
					else {
//						txt1RegErr = checkRegExp(textSeqStart.getText(),comboIndex);
//						txt1RegErr = checkRegExp(textSeqEnd.getText(),comboIndex);
						if (comboIndex != 7) {
							if (Integer.parseInt(textSeqEnd.getText()) > Integer.parseInt(textSeqStart.getText()) + 100) {
								textSeqEnd.setText(null);
								JOptionPane.showMessageDialog(null, "为避免浪费，不建议一次性列印超过100张条码，请重新输入结束序号！");
								return;
							}
						}
						if (Integer.parseInt(textSeqEnd.getText()) < Integer.parseInt(textSeqStart.getText())) {
							textSeqEnd.setText(null);
							JOptionPane.showMessageDialog(null, "结束序号不能小于起始序号！");
							return;
						}
						if ( textZaiJu.getText().matches("^[-a-zA-Z]{2}$") == false ) { 
							textZaiJu.requestFocus();
							JOptionPane.showMessageDialog(null, "请输入正确的载具识别类型（2位字符）！");
							return;
						}
						/*
						for (int i = Integer.parseInt(textSeqStart.getText()); i <= Integer
								.parseInt(textSeqEnd.getText()); i++) {
							if (!prt.barcodePrintMMCZaiJu(i, textZaiJu.getText(),prtIndex))
								return;
						}
						*/
						/** 贾维程 替换的内容
						 * @author 贾维程
						 * @date   2021-05-15
						 */
						if (radioButtonZebra.isSelected()){
							Print prt = new Print("init ZplPrinter");
							for (int i = Integer.parseInt(textSeqStart.getText()); i <= Integer
									.parseInt(textSeqEnd.getText()); i++) {
								if (!prt.barcodePrintMMCZaiJu(i, textZaiJu.getText(),prtIndex))
									return;
							}
						} else {
							List<String> barCodeList = new ArrayList<>();
							for (int i = Integer.parseInt(textSeqStart.getText()); i <= Integer
									.parseInt(textSeqEnd.getText()); i++) {
								try {
									barCodeList.add(prt2.getBarcodeMMCZaiJu(i, textZaiJu.getText()));
								} catch (Exception e1) {
									JOptionPane.showMessageDialog(null, "Windows打印获取条码异常！");
									return;
								}
							}
							WindowsPrint windowsPrint = new WindowsPrint(barCodeList);
							if(!windowsPrint.print()) return;
							else JOptionPane.showMessageDialog(null, "打印完成！");
						}
					}
					break;
				default:
					if (textSeqStart.getText().isEmpty() || textSeqEnd.getText().isEmpty()) {
						JOptionPane.showMessageDialog(null, "起讫序号不能为空，输入完毕才能列印！");
						return;
					} 
					else {
//						txt1RegErr = checkRegExp(textSeqStart.getText(),comboIndex);
//						txt1RegErr = checkRegExp(textSeqEnd.getText(),comboIndex);
						if (comboIndex != 7) {
							if (Integer.parseInt(textSeqEnd.getText()) > Integer.parseInt(textSeqStart.getText()) + 100) {
								textSeqEnd.setText(null);
								JOptionPane.showMessageDialog(null, "为避免浪费，不建议一次性列印超过100张条码，请重新输入结束序号！");
								return;
							}
						}
						if (Integer.parseInt(textSeqEnd.getText()) < Integer.parseInt(textSeqStart.getText())) {
							textSeqEnd.setText(null);
							JOptionPane.showMessageDialog(null, "结束序号不能小于起始序号！");
							return;
						}
						/*
						for (int i = Integer.parseInt(textSeqStart.getText()); i <= Integer
								.parseInt(textSeqEnd.getText()); i++) {
							if (!prt.barcodePrint(i, comboIndex,prtIndex))
								return;
						}
						*/
						/** 贾维程 替换的内容
						 * @author 贾维程
						 * @date   2021-05-15
						 */
						if (radioButtonZebra.isSelected()){
							Print prt = new Print("init ZplPrinter");
							for (int i = Integer.parseInt(textSeqStart.getText()); i <= Integer
									.parseInt(textSeqEnd.getText()); i++) {
								if (!prt.barcodePrint(i, comboIndex,prtIndex))
									return;
							}
						} else {
							List<String> barCodeList = new ArrayList<>();
							for (int i = Integer.parseInt(textSeqStart.getText()); i <= Integer
									.parseInt(textSeqEnd.getText()); i++) {
								try {
									barCodeList.add(prt2.getBarcode(i, comboIndex));
								} catch (Exception e1) {
									JOptionPane.showMessageDialog(null, "Windows打印获取条码异常！");
									return;
								}
							}
							WindowsPrint windowsPrint = new WindowsPrint(barCodeList);
							if(!windowsPrint.print()) return;
							else JOptionPane.showMessageDialog(null, "打印完成！");
						}
					}
					break;
				}
				textSeqStart.setText(null);
				textSeqEnd.setText(null);
				textField4.setText(null);
				textField5.setText(null);
				textField6.setText(null);
				textField7.setText(null);
				textField8.setText(null);
				textSeqNo.setText(null);
				textDianCangQu.setText(null);
				textDianCangDao.setText(null);
				textDianCangBei.setText(null);
				textDianCangCeng.setText(null);
				textDianCangGe.setText(null);
				textDianCangBar.setText(null);
				textZaiJu.setText(null);
				cmbDianCangLou.setSelectedIndex(0);
			}
		});
					
		JButton btnExit = new JButton("退出");
		btnExit.setFont(new Font("宋体", Font.PLAIN, 22));
		GridBagConstraints gbc_btnExit = new GridBagConstraints();
		gbc_btnExit.fill = GridBagConstraints.BOTH;
		gbc_btnExit.gridwidth = 2;
		gbc_btnExit.insets = new Insets(0, 0, 5, 5);
		gbc_btnExit.gridx = 7;
		gbc_btnExit.gridy = 7;
		panel.add(btnExit, gbc_btnExit);
		
		btnExit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
				
			}
		});
		
		JLabel labelVer = new JLabel("Ver 2.5 plus");
		labelVer.setFont(new Font("宋体", Font.PLAIN, 15));
		GridBagConstraints gbc_labelVer = new GridBagConstraints();
		gbc_labelVer.gridx = 9;
		gbc_labelVer.gridy = 8;
		panel.add(labelVer, gbc_labelVer);
		

		
	
	}
}
